<?php

namespace app\modules\cruise\models;

use Yii;

/**
 * This is the model class for table "room_code".
 *
 * @property int $id
 * @property int $cruise_id 邮轮ID
 * @property int $deck 甲板层数
 * @property string $code 房间号
 * @property int $type 房型
 * @property string $type_code 房型代码
 * @property int $num 房间入住最大人数
 * @property string $link_room 连通房
 * @property string $location svg坐标
 * @property string $remark 备注
 * @property int $status 1正常 2禁止
 * @property int $user_id 管理员编号
 * @property string $created_at
 * @property string $updated_at
 * @property string $color 房间颜色代码
 */
class RoomCode extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'room_code';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['cruise_id', 'deck', 'type', 'num', 'status', 'user_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['code', 'type_code', 'link_room', 'color'], 'string', 'max' => 20],
            [['location'], 'string', 'max' => 522],
            [['remark','bed'], 'string', 'max' => 256],
            [['cruise_id', 'code'], 'unique', 'targetAttribute' => ['cruise_id', 'code']],
        ];
    }


    //  获取对应游轮   
    public function getCruise(){
        return $this->hasOne(Cruise::className(), ['id' => 'cruise_id']);
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'cruise_id' => 'Cruise ID',
            'deck' => 'Deck',
            'code' => 'Code',
            'type' => 'Type',
            'type_code' => 'Type Code',
            'num' => 'Num',
            'link_room' => 'Link Room',
            'location' => 'Location',
            'remark' => 'Remark',
            'status' => 'Status',
            'user_id' => 'User ID',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'color' => 'Color',
            'bed' =>'详细床型',
        ];
    }
}
